package com.liu.demo6.service.iml;

import com.liu.demo6.Mapper.BlogMapper;
import com.liu.demo6.entity.Blog;
import com.liu.demo6.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogServiceIml implements BlogService {
    @Autowired
    BlogMapper blogMapper;
    @Override
    public List<Blog> findAll() {
        //查找所有博客，通过调用mapper对象的方法来实现
        return blogMapper.selectAll();
    }

    @Override
    public List<Blog> findByPage(int page, int size) {
        //查询分页数据
        //计算从第几行开始查询
        int offset = (page - 1) * size;
        return blogMapper.findBlogsByPage(offset, size);
    }
    //查询博客数量
    @Override
    public int count() {
        return blogMapper.countBlogs();
    }
}